package com.ruoyi.web.controller.project;

import com.google.common.collect.Lists;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Analysis;
import com.ruoyi.system.domain.ProjectManagement;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author zhaonz
 * @version 1.0
 * @date 2023/6/13 10:38
 */
@Controller
@RequestMapping("/project/analysis")
public class AnalysisController extends BaseController {

    private String prefix = "project/analysis";

    @RequiresPermissions("system:analysis:view")
    @GetMapping()
    public String analysis()
    {
        return prefix + "/analysis";
    }

    /**
     * 导出系统分析结果
     */
    @RequiresPermissions("system:analysis:export")
    @Log(title = "系统分析", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ProjectManagement projectManagement) {
//        List<ProjectManagement> list = projectManagementService.list(projectManagement);

        List<Analysis> list = Lists.newArrayList();

        Analysis analysis = new Analysis();

        analysis.setYear("2023");
        analysis.setBudget("2000");




        Analysis.Source source1 = new Analysis.Source();
        source1.setSchedule("123");
        source1.setTest("123");

        analysis.setSources(source1);


        list.add(analysis);

        ExcelUtil<Analysis> util = new ExcelUtil<Analysis>(Analysis.class);
        return util.exportExcel(list, "项目分析数据");
    }

}
